<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>开关灯</title>
		<script src="js/jquery-3.6.0.min.js"></script>
	</head>
	<body>
		<center><img src="img/off.png" width="180px"></center>
	<div id="div1" style="font-weight: 800;font-size: 20px;text-align: center;">灯灭了！！!</div>
	<script>
	var flag=false;
	$("img").eq(0).click(function(){
		if(flag){
			$("#div1").html("灯灭了！！！");
			$("img").eq(0).attr("src","img/off.png");
			flag=!flag;
		}else{
			$("#div1").html("灯亮了！！！");
			$("img").attr("src","img/on.png");
			flag=!flag;
		}
	});
	</script>
	</body>
</html>
